#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64
import hashlib
import hmac
from typing import Any

import requests
import time
import uuid
from urllib import parse
import  jwt
from flask import current_app
class AccessToken:
    @classmethod
    def create_toklen(cls,payload:dict,JWT_SECRET_KEY:str,algorithm:Any):
        token = jwt.encode(payload,JWT_SECRET_KEY, algorithm)
        return token

    @classmethod
    def decode_token(cls, token,JWT_SECRET_KEY,algorithm):
        try:
            payload = jwt.decode(token,JWT_SECRET_KEY, algorithm)
            return payload
        except jwt.ExpiredSignatureError:
            print("已过期")
            return None  # Token 已过期
        except jwt.InvalidTokenError:
            print("无效")
            return None  # Token 无效
